

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/e-page/news/img/favicon.ico">
  <link rel="icon" href="/e-page/news/img/favicon.ico">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="YanpingDong">
  <meta name="keywords" content="">
  
    <meta name="description" content="在创建hexo的项目的时候，会自动创建一个themes的目录，自定的主题或者在git上下载主题就可以放在这个目录下。最简单的主题结构如下：   _config.yml： 主题配置文件。 layout： 布局目录，放置hexo用于生成各种页面的模板ejs文件。 source： 主题资源目录，包括css、js、img等。这里的css、js、img等文件在其他ejs里应用的时候可以忽略source这一层">
<meta property="og:type" content="article">
<meta property="og:title" content="怎么编写hexo主题-简介 1">
<meta property="og:url" content="https://yanpingdong.gitee.io/e-page/2023/10/20/how-to-write-hexo-theme/index.html">
<meta property="og:site_name" content="e-page">
<meta property="og:description" content="在创建hexo的项目的时候，会自动创建一个themes的目录，自定的主题或者在git上下载主题就可以放在这个目录下。最简单的主题结构如下：   _config.yml： 主题配置文件。 layout： 布局目录，放置hexo用于生成各种页面的模板ejs文件。 source： 主题资源目录，包括css、js、img等。这里的css、js、img等文件在其他ejs里应用的时候可以忽略source这一层">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://yanpingdong.gitee.io/e-page/news/2023/10/20/how-to-write-hexo-theme/pic/my-theme-dir-layer.png">
<meta property="article:published_time" content="2023-10-20T08:42:12.000Z">
<meta property="article:modified_time" content="2023-10-24T08:38:27.088Z">
<meta property="article:author" content="YanpingDong">
<meta property="article:tag" content="js">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://yanpingdong.gitee.io/e-page/news/2023/10/20/how-to-write-hexo-theme/pic/my-theme-dir-layer.png">
  
  
  
  <title>怎么编写hexo主题-简介 1 - e-page</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/e-page/news/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/e-page/news/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/e-page/news/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"yanpingdong.gitee.io","root":"/e-page/news/","version":"1.9.5-a","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":{"measurement_id":null},"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/e-page/news/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/e-page/news/js/utils.js" ></script>
  <script  src="/e-page/news/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 60vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/e-page/news/">
      <strong>e-page</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/../">
                <i class="iconfont icon-home-fill"></i>
                <span>Home</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/">
                <i class="iconfont icon-books"></i>
                <span>News</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>Archives</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>Categories</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>Tag</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/e-page/news/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>About</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/e-page/news/img/bg/banner.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="怎么编写hexo主题-简介 1"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2023-10-20 16:42" pubdate>
          2023年10月20日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          3.7k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          31 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">怎么编写hexo主题-简介 1</h1>
            
            
              <div class="markdown-body">
                
                <p>在创建hexo的项目的时候，会自动创建一个themes的目录，自定的主题或者在git上下载主题就可以放在这个目录下。最简单的主题结构如下：</p>
<p><img src="/e-page/news/2023/10/20/how-to-write-hexo-theme/pic/hexo-dir-layer.png" srcset="/e-page/news/img/loading.gif" lazyload></p>
<ul>
<li>_config.yml： 主题配置文件。</li>
<li>layout： 布局目录，放置hexo用于生成各种页面的模板ejs文件。</li>
<li>source： 主题资源目录，包括css、js、img等。这里的css、js、img等文件在其他ejs里应用的时候可以忽略source这一层，直接引用，如下所示。<br><img src="/e-page/news/2023/10/20/how-to-write-hexo-theme/pic/refer-js-css-in-hexo.png" srcset="/e-page/news/img/loading.gif" lazyload></li>
<li>scripts： 主题脚本文件,在启动hexo时会执行，如果没特别需求可以不要。</li>
</ul>
<p>修改项目根目录下的 _config.yml 内的 theme 设定，即可切换主题。</p>
<p><strong>layout中的一些文件：</strong></p>
<ul>
<li>layout.ejs： 所有网页的公共布局页面（也可以理解成主页面、分裂、归档、tag、blog、自定义页面的渲染模板，只是在渲染不同类型的页面的时候替换的body值不同），可以在改文件里面添加一些公共的css、js、header、footer等。一般通过该文件定义好整体的页面布局，这里面的&lt;%- body %&gt;在随着路径的不同输出内容是不一样的！！！一个简单的layout.ejs如下如下所示：<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span><br><span class="hljs-comment">&lt;!-- Head tag --&gt;</span><br>&lt;%- partial(&#x27;_partial/head&#x27;) %&gt;<br><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <span class="hljs-comment">&lt;!-- Menu --&gt;</span><br>    &lt;%- partial(&#x27;_partial/menu&#x27;) %&gt;<br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">main</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;page main-page&quot;</span>&gt;</span><br>        &lt;%- body %&gt;<br>    <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span><br>    <span class="hljs-comment">&lt;!-- Footer --&gt;</span><br>    &lt;%- partial(&#x27;_partial/footer&#x27;) %&gt;<br>    <span class="hljs-comment">&lt;!-- After footer scripts --&gt;</span><br>    &lt;%- partial(&#x27;_partial/after-footer&#x27;) %&gt;<br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure></li>
<li>index.ejs： 主页内容模板，也就在访问根目录时候layout.ejs使用&lt;%- body %&gt;输出的内容。</li>
<li>_partial目录： 该目录可以自定义名称，可用于存放一些公共的html片段，比如header、footer、menu等。在 EJS 中，_partial 通常是一个包含所有 partial 模板的文件夹，所以本文也用该名称。可以使用 EJS 中用于包含其他模板的函数partial来引用模板代码片段，比如<code>&lt;%- partial(&#39;_partial/footer&#39;) %&gt;</code>。</li>
<li>archive.ejs: 文章归档页面模板，访问&#x2F;archives&#x2F;时输出。Hexo 内置了对归档页面的支持，因此只需创建 archive.ejs 模板文件。即可直接访问&#x2F;archives&#x2F;时输出到layout.ejs的&lt;%- body %&gt;。</li>
<li>category.ejs: 分类页面模板，访问&#x2F;categories&#x2F;{category}，时输出到layout.ejs的&lt;%- body %&gt;。但并没内置支持！</li>
<li>tag.ejs: 标签页面模板，访问&#x2F;tags&#x2F;{tag}，时输出到layout.ejs的&lt;%- body %&gt;。但并没内置支持！</li>
<li>post.ejs: 文章页面模板，访问&#x2F;post&#x2F;某文章名称，时输出到layout.ejs的&lt;%- body %&gt;。</li>
<li>page.ejs: 特殊页面渲染模板，除了post、page、archive、category、tag等页面，自己定义的页面时输出到layout.ejs的&lt;%- body %&gt;。</li>
</ul>
<p><strong>总结表格</strong></p>
<p>layout.ejs是所有页面公用的布局，只是在不同的路径下使用不同的index.ejs,archive.ejs,post.ejs等来替换&lt;%- body %&gt;值！！！</p>
<table>
<thead>
<tr>
<th>功能</th>
<th>访问路径</th>
<th>对应layout中body的文件名</th>
<th>作用</th>
</tr>
</thead>
<tbody><tr>
<td>入口</td>
<td>无或&#x2F;</td>
<td>&#x2F;layout&#x2F;index.ejs</td>
<td>主题入口,&lt;%- body %&gt;值是&#x2F;layout&#x2F;index.ejs</td>
</tr>
<tr>
<td>归档</td>
<td>&#x2F;archives&#x2F;</td>
<td>&#x2F;layout&#x2F;archive.ejs</td>
<td>归档，包含所有的文章，一般按文章的时间排序，内置支持！</td>
</tr>
<tr>
<td>分类</td>
<td>&#x2F;categories&#x2F;</td>
<td>&#x2F;layout&#x2F;category.ejs</td>
<td>显示全部分类文章，含分页，没内置支持！</td>
</tr>
<tr>
<td>具体分类</td>
<td>&#x2F;categories&#x2F;{category}&#x2F;</td>
<td>&#x2F;layout&#x2F;category.ejs</td>
<td>显示指定类型分类的页面，含分页;&lt;%- body %&gt;值的优先填充是&#x2F;layout&#x2F;category.ejs&gt;&#x2F;layout&#x2F;archive.ejs&gt;&#x2F;layout&#x2F;index.ejs</td>
</tr>
<tr>
<td>标签</td>
<td>&#x2F;tags&#x2F;</td>
<td>&#x2F;layout&#x2F;tag.ejs</td>
<td>显示全部标签，含分页，没内置支持！</td>
</tr>
<tr>
<td>具体标签</td>
<td>&#x2F;tags&#x2F;{tag}&#x2F;</td>
<td>&#x2F;layout&#x2F;tag.ejs</td>
<td>显示某一个标签的页面，含分页；&lt;%- body %&gt;值的优先填充是&#x2F;layout&#x2F;tag.ejs&gt;&#x2F;layout&#x2F;archive.ejs&gt;&#x2F;layout&#x2F;index.ejs</td>
</tr>
<tr>
<td>博客内容</td>
<td>&#x2F;年&#x2F;月&#x2F;日&#x2F;博客的文件名称&#x2F;</td>
<td>&#x2F;layout&#x2F;post.ejs</td>
<td>具体一篇文章的详细内容页面，一般包含前一篇和后一篇的功能,请注意和分页功能不同，一页可以有多个文章！</td>
</tr>
<tr>
<td>自定义页面</td>
<td>&#x2F;页眉路径&#x2F;</td>
<td>&#x2F;layout&#x2F;custum-page.ejs</td>
<td>比如about界面，自定的名称就是页眉路径，about就是&#x2F;about&#x2F;</td>
</tr>
</tbody></table>
<p>所以一般简单的主题只需要写layout.ejs,index.ejs,archive.ejs,post.ejs这几个模板即可！如果不需要区分index和各个分类的页面，只需要layout.ejs,index.ejs,post.ejs。</p>
<h2 id="hexo的启动流程"><a href="#hexo的启动流程" class="headerlink" title="hexo的启动流程"></a>hexo的启动流程</h2><ol>
<li>读取scripts下的脚本并执行。</li>
<li>读取layout目录下的layout.ejs文件。</li>
<li>为主页面、分裂、归档、tag、blog、自定义页面，渲染layout.ejs中干的&lt;%- body %&gt;数据。</li>
</ol>
<h2 id="一个简单的hexo主题"><a href="#一个简单的hexo主题" class="headerlink" title="一个简单的hexo主题"></a>一个简单的hexo主题</h2><p>依据上面的介绍，我们可以自己写一个hexo主题，这里以一个简单的主题为例，来介绍hexo主题的搭建。简单的目录结构如下所示：</p>
<p><img src="/e-page/news/2023/10/20/how-to-write-hexo-theme/pic/my-theme-dir-layer.png" srcset="/e-page/news/img/loading.gif" lazyload></p>
<h3 id="创建模板layout-ejs"><a href="#创建模板layout-ejs" class="headerlink" title="创建模板layout.ejs"></a>创建模板layout.ejs</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>    <br>        <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span> Layout <span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span><br>            &lt;%- body %&gt;<br>        <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h3 id="创建首页内容模板index-ejs"><a href="#创建首页内容模板index-ejs" class="headerlink" title="创建首页内容模板index.ejs"></a>创建首页内容模板index.ejs</h3><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Hello World,My Index Page<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span><br></code></pre></td></tr></table></figure>

<h3 id="创建scripts目录下启动所需脚本start-js"><a href="#创建scripts目录下启动所需脚本start-js" class="headerlink" title="创建scripts目录下启动所需脚本start.js"></a>创建scripts目录下启动所需脚本start.js</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">&quot;===================start my-theme======================&quot;</span>)<br></code></pre></td></tr></table></figure>

<h3 id="启动结果："><a href="#启动结果：" class="headerlink" title="启动结果："></a>启动结果：</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs sh">$ hexo s<br>INFO  Validating config<br>===================start my-theme======================<br>INFO  Start processing<br>INFO  Hexo is running at http://localhost:4000/e-page/my-theme/ . Press Ctrl+C to stop.<br></code></pre></td></tr></table></figure>

<h3 id="页面"><a href="#页面" class="headerlink" title="页面"></a>页面</h3><p><img src="/e-page/news/2023/10/20/how-to-write-hexo-theme/pic/my-theme-demo-1.png" srcset="/e-page/news/img/loading.gif" lazyload></p>
<p>从页面源代码中可以看到首页的&lt;%- body %&gt;已经被index.ejs里面的内容替换掉：</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span><br><br><span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><br>   <br>    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span> Layout <span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Hello World,My Index Page<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p><strong>欢迎关注微信公众号，更多文章分享。</strong> <img src="/e-page/news/img/qrcode_for_ITSuperDaddy.jpg" srcset="/e-page/news/img/loading.gif" lazyload></p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/e-page/news/categories/%E5%89%8D%E7%AB%AF/" class="category-chain-item">前端</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/e-page/news/tags/js/" class="print-no-link">#js</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>怎么编写hexo主题-简介 1</div>
      <div>https://yanpingdong.gitee.io/e-page/2023/10/20/how-to-write-hexo-theme/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>YanpingDong</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年10月20日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/e-page/news/2023/10/23/how-to-write-hexo-theme-layout/" title="怎么编写hexo主题-layout 2">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">怎么编写hexo主题-layout 2</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/e-page/news/2023/10/09/java-build-tool-ant/" title="java构建工具ant简述">
                        <span class="hidden-mobile">java构建工具ant简述</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>E-page</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.4/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/e-page/news/js/events.js" ></script>
<script  src="/e-page/news/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/e-page/news/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.20.1/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/e-page/news/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/e-page/news/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
